﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _77_C_反射可能破坏单例模式
{
    internal class Student
    {
        private static Student _instance = null;
        private static object obj = new object();

        private Student()
        {
            Console.WriteLine("调用构造函数");
        }

        public static Student GetInstance()
        {
            if (_instance == null)
            {
                lock (obj)
                {
                    if (_instance == null)
                    {
                        _instance = new Student();
                    }
                }
            }
            return _instance;
        }
    }
}
